<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>车辆批量导入</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.2.1/css/bootstrap.min.css" >
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
    <link rel="stylesheet" href="https://lib.baomitu.com/bootstrap-table/1.13.1/bootstrap-table.min.css">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.6.2/core.min.js"></script>
    <script src="https://lib.baomitu.com/bootstrap-table/1.13.1/bootstrap-table.min.js"></script>
    <script src="https://lib.baomitu.com/bootstrap-table/1.13.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <!-- 引入layer -->
    <script type="text/javascript" src="https://lib.baomitu.com/layer/3.1.1/layer.js"></script>
</head>
<body>
    <form method="POST" enctype="multipart/form-data" action="/lisa-auto/vehicles/importVehicleExcel">
        <label>车辆批量导入：</label><input class="form-control" placeholder="车辆批量导入" type="file" name="file" id="vehicleFile"/><br>
        <input type="submit" value="导入">
    </form>
</body>
    <script type="text/javascript">
        $(function() {
            $('#submit').click(function() {
                var curWwwPath = window.location.href;
                var pathName = window.location.pathname;
                var local = curWwwPath.substring(0,curWwwPath.indexOf(pathName));
                var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
                var rootPath = local + projectName;
                var formData = new FormData();
                formData.append("vehicleFile", $("#vehicleFile").val());
                $.ajax({
                    url: rootPath + "/vehicles/importVehicleExcel",
                    type: "POST",
                    data: formData,
                    processData: false,  // 告诉jQuery不要去处理发送的数据
                    contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
                    success: function (responseText) {
                        alert(responseText);
                    }
                });
            });
        });
    </script>

</html>